package org.framework.factory;

import org.framework.config.MessagePorducerInvocationHandler;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.FactoryBean;

/**
 * @ClassName MessageProducerFactoryBean
 * @Description
 * @Author RayLiang
 * @Date 2022/12/12 15:22
 * @Version 1.0
 **/
public class MessageProducerFactoryBean<T> implements FactoryBean<T> {
    private Class<?> type;
    private boolean callBackFlag;

    public MessageProducerFactoryBean(Class<?> type, boolean callBackFlag) {

        this.type = type;
        this.callBackFlag = callBackFlag;
    }

    @Override
    public T getObject() {
        return (T) MessagePorducerInvocationHandler.generateProxyClass(this.type, this.callBackFlag);
    }

    @Override
    public Class<?> getObjectType() {
        return type;
    }
}
